package com.chinacoal.microservice;


import com.chinacoal.microservice.fallback.WechatClientFallback;
import com.chinacoal.microservice.util.PassToken;
import com.chinacoal.microservice.util.Result;
import com.chinacoal.microservice.util.UserLoginToken;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 微信
 * @date 2020-12-21 9：57
 */
@Api(tags = {"微信"})
@FeignClient(name = "${spring.application.name}",fallback = WechatClientFallback.class,configuration = FeignAutoConfiguration.class)
public interface WechatClient {

    /**
     * @Description: 用户名，密码登录
     * @author zhuliang
     * @date 2020/12/21 18:16
     */
    @ApiOperation(value = "用户名，密码登录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "userName", value = "登录名", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "path", name = "passWord", value = "密码", required = true, dataType = "String")
    })
    @GetMapping("smartleasing/wechat/{userName}/{passWord}")
    public Result<String> usernamePasswordLogin(@PathVariable(value = "userName") String userName,
                                                @PathVariable(value = "passWord") String passWord);

    /**
     * @Description: 发送验证码
     * @author zhuliang
     * @date 2020/12/22 9:41
     */
    @ApiOperation(value = "发送验证码")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "phoneNumber", value = "电话号码", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "path", name = "type", value = "类型，0登录，1修改密码", required = true, dataType = "Integer")
    })
    @GetMapping("smartleasing/wechat/verificationCode/{phoneNumber}/{type}")
    public Result verificationCode(@PathVariable(value = "phoneNumber") String phoneNumber,
                                   @PathVariable(value = "type") Integer type);

    /**
     * @Description: 验证码登录
     * @author zhuliang
     * @date 2020/12/22 13:52
     */
    @ApiOperation(value = "验证码登录")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "phoneNumber", value = "电话号码", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "path", name = "verificationCode", value = "验证码", required = true, dataType = "int")
    })
    @GetMapping("smartleasing/wechat/verificationCodeLogin/{phoneNumber}/{verificationCode}")
    public Result<String> verificationCodeLogin(@PathVariable(value = "phoneNumber") String phoneNumber,
                                                @PathVariable(value = "verificationCode") int verificationCode);

    /**
     * @Description: 获得openId
     * @author zhuliang
     * @date 2020/12/24 16:39
     */
    @ApiOperation(value = "获得openId")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "path", name = "code", value = "微信用户的code", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "令牌", required = true, dataType = "String")
    })
    @GetMapping("smartleasing/wechat/getOpenId/{code}")
    public Result getOpenId(@PathVariable(value = "code") String code,
                            @RequestHeader(value = "token") String token);

    /**
     * @Description: 添加用户的openId
     * @author zhuliang
     * @date 2021/2/2 11:03
     */
    @ApiOperation(value = "添加用户的openId")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "openId", value = "微信用户的openId", required = true, dataType = "String"),
            @ApiImplicitParam(paramType = "header", name = "token", value = "令牌", required = true, dataType = "String")
    })
    @PostMapping("smartleasing/wechat/addOpenId")
    public Result addOpenId(@RequestParam(value = "openId") String openId,
                            @RequestHeader(value = "token") String token);
}
